/*
 * Copyright 2011 CraneLeeon authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.crane.webtemplate;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author CraneLeeon
 */
public class Tokens {
    public static final int ACT_ERROR = -1;
    public static final int ACT_LIST = 0;
    public static final int ACT_GET = 1;
    public static final int ACT_SAVE = 2;
    public static final int ACT_DELETE = 3;
    public static final int ACT_CREATE = 4;
    public static final int ACT_UPDATE = 5;
    public static final int ACT_CANCEL = 6;
    public static final int ACT_Combo = 7;
    
    public static final int ACT_NOTIFICATIONS = 10;

    public static final int ACT_EXPORT_CSV=41;
    public static final int ACT_EXPORT_JSON=42;
    public static final int ACT_EXPORT_XML=43;
    
    public static final int ACT_LOGIN = 51;
    public static final int ACT_LOGOUT = 52;

    
    
    public static final int ACT_SAY_HI = 1000;
    

    public static final int ERR_UNKNOWN = -1;
    public static final int ERR_IO = 0;

    public static final int ERR_USER_NOT_AUTHORIZED = 10;
    
    public static final int ERR_UNIQUE_CONSTRAINT_VIOLATION = 1000;

    public static final Map<String, Integer> ALL_ACT = new HashMap();
    static{
        Tokens ins = new Tokens();
        for(Field field : Tokens.class.getDeclaredFields()){
            try {
                if(Modifier.isStatic(field.getModifiers()) && field.getName().startsWith("ACT_")){
                    ALL_ACT.put(field.getName(), field.getInt(ins));
                }
            } catch (IllegalArgumentException ex) {
            } catch (IllegalAccessException ex) {
            }
        }
    }
    
    public static final Map<String, Integer> ALL_ERR = new HashMap();
    static{
        Tokens ins = new Tokens();
        for(Field field : Tokens.class.getDeclaredFields()){
            try {
                if(Modifier.isStatic(field.getModifiers()) && field.getName().startsWith("ERR_")){
                    ALL_ERR.put(field.getName(), field.getInt(ins));
                }
            } catch (IllegalArgumentException ex) {
            } catch (IllegalAccessException ex) {
            }
        }
    }

}
